<?php

namespace App\Api\Controllers\Config;


use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class Dong_GuanConfigController extends Controller
{
    private $wx_appid = 'wx4e41b2f311ded3b1';
    private $wx_secret = 'fa265a8e5e4569d1ad18f08ef71a7301';

    public function getConfig($store_id, $store_pid)
    {
        $result = false;
        $storeConfig = DB::table('dongguanbank_stores')->where('store_id', $store_id)->select(['mch_id', 'op_device_id', 'private_key'])->first();
        if (!$storeConfig) {
            $parent_id = DB::table('stores')->where('id', $store_id)->value('store_id');
            $storeConfig = DB::table('dongguanbank_stores')->where('store_id', $parent_id)->select(['mch_id', 'op_device_id', 'private_key'])->first();
        }
        if ($storeConfig) {
            $result = array_merge((array)$storeConfig, ['appid' => $this->wx_appid, 'secret' => $this->wx_secret]);
        }
        return $result;
    }
}
